package com.wzy.new_energy_car_platform.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.wzy.new_energy_car_platform.common.ResultDto;
import com.wzy.new_energy_car_platform.dao.CarCircleMapper;
import com.wzy.new_energy_car_platform.model.CarCircle;
import com.wzy.new_energy_car_platform.service.CarCircleService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 车友圈 服务实现类
 * </p>
 *
 * @author wzy
 * @since 2024-04-09
 */
@Service
public class CarCircleServiceImpl extends ServiceImpl<CarCircleMapper, CarCircle> implements CarCircleService {
    @Autowired
    private CarCircleMapper carCircleMapper;

    @Override
    public ResultDto<?> getCarCircle() {
        LambdaQueryWrapper<CarCircle> carCircleLambdaQueryWrapper = new LambdaQueryWrapper<>();
        carCircleLambdaQueryWrapper.orderByDesc(CarCircle::getNum)
                .last("limit 10");
        List<CarCircle> carCircles = carCircleMapper.selectList(carCircleLambdaQueryWrapper);
        return ResultDto.ok(carCircles);
    }
}
